package org.application.Entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.dxy.domain.game.model.entity.PieceEntity;
import org.dxy.types.enums.PieceColorEnum;
import org.dxy.types.enums.PieceNameEnum;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class BoardEntity {

    private Long id;

    /**
     * 棋盘的行数。
     */
    private int rows = 10;

    /**
     * 棋盘的列数。
     */
    private int columns = 9;

    private PieceEntity[][] board;


    public void initializeBoard() {
        // 初始化红方棋子
        // 车（Rook）
        board[0][0] = PieceEntity.builder().pieceId(1L).row(0).column(0).pieceName(PieceNameEnum.ROOK).pieceColorEnum(PieceColorEnum.RED).build();
        board[0][8] = PieceEntity.builder().pieceId(2L).row(0).column(8).pieceName(PieceNameEnum.ROOK).pieceColorEnum(PieceColorEnum.RED).build();
        // 马（Knight）
        board[0][1] = PieceEntity.builder().pieceId(3L).row(0).column(1).pieceName(PieceNameEnum.KNIGHT).pieceColorEnum(PieceColorEnum.RED).build();
        board[0][7] = PieceEntity.builder().pieceId(4L).row(0).column(7).pieceName(PieceNameEnum.KNIGHT).pieceColorEnum(PieceColorEnum.RED).build();
        // 相（Minister）
        board[0][2] = PieceEntity.builder().pieceId(5L).row(0).column(2).pieceName(PieceNameEnum.MINISTER).pieceColorEnum(PieceColorEnum.RED).build();
        board[0][6] = PieceEntity.builder().pieceId(6L).row(0).column(6).pieceName(PieceNameEnum.MINISTER).pieceColorEnum(PieceColorEnum.RED).build();
        // 士（Advisor）
        board[0][3] = PieceEntity.builder().pieceId(7L).row(0).column(3).pieceName(PieceNameEnum.ADVISOR).pieceColorEnum(PieceColorEnum.RED).build();
        board[0][5] = PieceEntity.builder().pieceId(8L).row(0).column(5).pieceName(PieceNameEnum.ADVISOR).pieceColorEnum(PieceColorEnum.RED).build();
        // 帅（King）
        board[0][4] = PieceEntity.builder().pieceId(9L).row(0).column(4).pieceName(PieceNameEnum.KING).pieceColorEnum(PieceColorEnum.RED).build();
        // 炮（Cannon）
        board[2][1] = PieceEntity.builder().pieceId(10L).row(2).column(1).pieceName(PieceNameEnum.CANNON).pieceColorEnum(PieceColorEnum.RED).build();
        board[2][7] = PieceEntity.builder().pieceId(11L).row(2).column(7).pieceName(PieceNameEnum.CANNON).pieceColorEnum(PieceColorEnum.RED).build();
        // 兵（Pawn）
        board[3][0] = PieceEntity.builder().pieceId(12L).row(3).column(0).pieceName(PieceNameEnum.PAWN).pieceColorEnum(PieceColorEnum.RED).build();
        board[3][2] = PieceEntity.builder().pieceId(13L).row(3).column(2).pieceName(PieceNameEnum.PAWN).pieceColorEnum(PieceColorEnum.RED).build();
        board[3][4] = PieceEntity.builder().pieceId(14L).row(3).column(4).pieceName(PieceNameEnum.PAWN).pieceColorEnum(PieceColorEnum.RED).build();
        board[3][6] = PieceEntity.builder().pieceId(15L).row(3).column(6).pieceName(PieceNameEnum.PAWN).pieceColorEnum(PieceColorEnum.RED).build();
        board[3][8] = PieceEntity.builder().pieceId(16L).row(3).column(8).pieceName(PieceNameEnum.PAWN).pieceColorEnum(PieceColorEnum.RED).build();

        // 初始化黑方棋子
        // 车（Rook）
        board[9][0] = PieceEntity.builder().pieceId(20L).row(9).column(0).pieceName(PieceNameEnum.ROOK).pieceColorEnum(PieceColorEnum.BLACK).build();
        board[9][8] = PieceEntity.builder().pieceId(21L).row(9).column(8).pieceName(PieceNameEnum.ROOK).pieceColorEnum(PieceColorEnum.BLACK).build();
        // 马（Knight）
        board[9][1] = PieceEntity.builder().pieceId(22L).row(9).column(1).pieceName(PieceNameEnum.KNIGHT).pieceColorEnum(PieceColorEnum.BLACK).build();
        board[9][7] = PieceEntity.builder().pieceId(23L).row(9).column(7).pieceName(PieceNameEnum.KNIGHT).pieceColorEnum(PieceColorEnum.BLACK).build();
        // 象（Elephant）
        board[9][2] = PieceEntity.builder().pieceId(24L).row(9).column(2).pieceName(PieceNameEnum.ELEPHANT).pieceColorEnum(PieceColorEnum.BLACK).build();
        board[9][6] = PieceEntity.builder().pieceId(25L).row(9).column(6).pieceName(PieceNameEnum.ELEPHANT).pieceColorEnum(PieceColorEnum.BLACK).build();
        // 士（Advisor）
        board[9][3] = PieceEntity.builder().pieceId(26L).row(9).column(3).pieceName(PieceNameEnum.ADVISOR).pieceColorEnum(PieceColorEnum.BLACK).build();
        board[9][5] = PieceEntity.builder().pieceId(27L).row(9).column(5).pieceName(PieceNameEnum.ADVISOR).pieceColorEnum(PieceColorEnum.BLACK).build();
        // 将（General）
        board[9][4] = PieceEntity.builder().pieceId(28L).row(9).column(4).pieceName(PieceNameEnum.GENERAL).pieceColorEnum(PieceColorEnum.BLACK).build();
        // 炮（Cannon）
        board[7][1] = PieceEntity.builder().pieceId(29L).row(7).column(1).pieceName(PieceNameEnum.CANNON).pieceColorEnum(PieceColorEnum.BLACK).build();
        board[7][7] = PieceEntity.builder().pieceId(30L).row(7).column(7).pieceName(PieceNameEnum.CANNON).pieceColorEnum(PieceColorEnum.BLACK).build();
        // 卒（Soldier）
        board[6][0] = PieceEntity.builder().pieceId(31L).row(6).column(0).pieceName(PieceNameEnum.SOLDIER).pieceColorEnum(PieceColorEnum.BLACK).build();
        board[6][2] = PieceEntity.builder().pieceId(32L).row(6).column(2).pieceName(PieceNameEnum.SOLDIER).pieceColorEnum(PieceColorEnum.BLACK).build();
        board[6][4] = PieceEntity.builder().pieceId(33L).row(6).column(4).pieceName(PieceNameEnum.SOLDIER).pieceColorEnum(PieceColorEnum.BLACK).build();
        board[6][6] = PieceEntity.builder().pieceId(34L).row(6).column(6).pieceName(PieceNameEnum.SOLDIER).pieceColorEnum(PieceColorEnum.BLACK).build();
        board[6][8] = PieceEntity.builder().pieceId(35L).row(6).column(8).pieceName(PieceNameEnum.SOLDIER).pieceColorEnum(PieceColorEnum.BLACK).build();
    }

}
